const formHandler = {
	updateEditStatus(operation, formItems) {
		if (operation === "update") {
			formItems.forEach(item => {
				if (!Boolean(item.isEdit)) {
					item.disabled = true;
				}
			});
		} else if (operation === "add") {
			formItems.forEach(item => {
				if (item.prop && item.prop !== "id") {
					item.disabled = false;
				}
			});
		}
	},

	handleParams(route) {
		if (route.params && route.params.action === "update") {
			return route.params.data;
		} else {
			return {};
		}
	},

	handleAction(route) {
		if (route.params && route.params.action === "update") {
			return "update";
		} else {
			return "add";
		}
	}
};

export default formHandler;
